/*
 * @Author: Damon Liu
 * @Date: 2024-11-21 00:12:06
 * @LastEditors: Damon Liu
 * @LastEditTime: 2025-04-30 17:32:35
 * @Description: 
 */
import { ipcRenderer, contextBridge } from 'electron'

// --------- Expose some API to the Renderer process ---------
contextBridge.exposeInMainWorld('ipcRenderer', {
  on(...args) {
    const [channel, listener] = args
    return ipcRenderer.on(channel, (event, ...args) => listener(event, ...args))
  },
  off(...args) {
    const [channel, ...omit] = args
    return ipcRenderer.off(channel, ...omit)
  },
  send(...args) {
    const [channel, ...omit] = args
    return ipcRenderer.send(channel, ...omit)
  },
  invoke(...args) {
    const [channel, ...omit] = args
    return ipcRenderer.invoke(channel, ...omit)
  },

  // 获取基础设置
  getBaseSettings: () => { return ipcRenderer.invoke('getBaseSettings') },

  // 更新基础设置
  updateBaseSettings: (_newSetting) => { return ipcRenderer.invoke('updateBaseSettings',_newSetting ) },

  // 路由跳转
  onNavigateTo: (callback) => { return ipcRenderer.on('navigate-to', (_event, _name) => callback(_name)) },


  // 获取本周日程
  getWeekSchedules: (weekStart) => { return ipcRenderer.invoke('getWeekSchedules', weekStart) },

  // 获取日程列表
  getSchedules: () => { return ipcRenderer.invoke('getSchedules') },

  // 获取每日日程
  getDailySchedules: (date) => { return ipcRenderer.invoke('getDailySchedules', date) },

  // You can expose other APTs you need here.
  // ...
})
